//@author A0081058H
package net.mysoc.w111j.ui.expenselist;

import java.util.List;

import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import net.mysoc.w111j.model.Expense;
import net.mysoc.w111j.service.filters.ExpenseFilter;

/**
 * The model for the expense list. Contains the current query and current search result.
 */
public class ExpenseListModel {
    private final ObservableList<Expense> expenseListProperty;
    private final StringProperty newCategoryFieldProperty;
    private final StringProperty newPaymentTypeFieldProperty;
    private final StringProperty listHeaderText;
    private ExpenseFilter expenseFilter;
    private final DoubleProperty scrollPaneLocationProperty;

    /**
     * Default constructor.
     *
     * @param dummyExpenseList
     *
     * @param defaultQuery
     *        the results of the default query.
     */
    public ExpenseListModel() {
        // Should get listHeaderText from query, maybe
        this.listHeaderText = new SimpleStringProperty();
        this.newCategoryFieldProperty = new SimpleStringProperty();
        this.newPaymentTypeFieldProperty = new SimpleStringProperty();
        this.expenseListProperty = FXCollections.observableArrayList();
        this.scrollPaneLocationProperty = new SimpleDoubleProperty();
    }

    public ObservableList<Expense> expenseListProperty() {
        return this.expenseListProperty;
    }

    public void setExpenseList(List<Expense> expenses) {
        this.expenseListProperty.clear();
        this.expenseListProperty.addAll(expenses);
    }

    public StringProperty listHeaderTextProperty() {
        return this.listHeaderText;
    }

    public String getListHeaderText() {
        return this.listHeaderText.get();
    }

    public void setListHeaderText(String query) {
        this.listHeaderText.set(query);
    }

    public StringProperty newCategoryFieldProperty() {
        return this.newCategoryFieldProperty;
    }

    public String getNewCategoryField() {
        return this.newCategoryFieldProperty.get();
    }

    public void setNewCategoryField(String text) {
        this.newCategoryFieldProperty.set(text);
    }

    public StringProperty newPaymentTypeFieldProperty() {
        return this.newPaymentTypeFieldProperty;
    }

    public String getNewPaymentTypeField() {
        return this.newPaymentTypeFieldProperty.get();
    }

    public void setNewPaymentTypeField(String text) {
        this.newPaymentTypeFieldProperty.set(text);
    }

    public ExpenseFilter getExpenseFilter() {
        return this.expenseFilter;
    }

    public void setExpenseFilter(ExpenseFilter expenseFilter) {
        this.expenseFilter = expenseFilter;
    }

    public DoubleProperty scrollPaneLocationProperty() {
        return this.scrollPaneLocationProperty;
    }

    public double getscrollPaneLocation() {
        return this.scrollPaneLocationProperty.get();
    }

    public void setscrollPaneLocation(Double d) {
        this.scrollPaneLocationProperty.set(d);
    }
}
